package main

import (
	"errors"
	"fmt"
	"reflect"
)

func Contain(obj interface{}, target interface{}) (bool, error) {
	targetValue := reflect.ValueOf(target)
	switch reflect.TypeOf(target).Kind() {
	case reflect.Slice, reflect.Array:
		for i := 0; i < targetValue.Len(); i++ {
			if targetValue.Index(i).Interface() == obj {
				return true, nil
			}
		}
	case reflect.Map:
		if targetValue.MapIndex(reflect.ValueOf(obj)).IsValid() {
			return true, nil
		}
	}

	return false, errors.New("not in array")
}

func main()  {
	aa:=map[string]string{"111":"cdds","222":"esad","2355":"sdawae"}
	a := "222"
	ok,_:=Contain(a,aa)
	fmt.Println(ok)
}


